<template>
  <button 
    class="nav-button"
    :class="{ active }"
    @click="$emit('click')"
    :title="label"
  >
    <div class="nav-icon">{{ icon }}</div>
    <div class="nav-label">{{ label }}</div>
    <div v-if="badge" class="nav-badge">{{ badge }}</div>
  </button>
</template>

<script setup lang="ts">
interface Props {
  icon: string
  label: string
  active?: boolean
  badge?: string | number
}

defineProps<Props>()
defineEmits<{
  click: []
}>()
</script>

<style scoped>
.nav-button {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  color: #cccccc;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  border-left: 3px solid transparent;
}

.nav-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-left-color: rgba(0, 212, 255, 0.5);
}

.nav-button.active {
  background: rgba(0, 212, 255, 0.2);
  color: #00d4ff;
  border-left-color: #00d4ff;
}

.nav-icon {
  font-size: 1.2rem;
  margin-right: 0.75rem;
  min-width: 20px;
  text-align: center;
}

.nav-label {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
}

.nav-badge {
  background: #ff4444;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 0.2rem 0.4rem;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  line-height: 1;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .nav-button {
    padding: 0.5rem;
    justify-content: center;
  }
  
  .nav-label {
    display: none;
  }
  
  .nav-icon {
    margin-right: 0;
  }
  
  .nav-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    font-size: 0.6rem;
    padding: 0.1rem 0.3rem;
  }
}

/* 动画效果 */
.nav-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 212, 255, 0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.nav-button:hover::before {
  transform: translateX(100%);
}
</style>